
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>外部构建启动合约 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="chap10.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    编译部署
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="chap1.html">
            
                <a href="chap1.html">
            
                    
                    编译与测试网络部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="chap2.html">
            
                <a href="chap2.html">
            
                    
                    网络生成配置说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="chap3.html">
            
                <a href="chap3.html">
            
                    
                    启动网络脚本配置剖析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    通道实践
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="chap4.html">
            
                <a href="chap4.html">
            
                    
                    创建加入通道
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="chap5.html">
            
                <a href="chap5.html">
            
                    
                    更新通道配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="chap6.html">
            
                <a href="chap6.html">
            
                    
                    动态添加组织
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    合约实践
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="chap7.html">
            
                <a href="chap7.html">
            
                    
                    安装发布智能合约
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="chap8.html">
            
                <a href="chap8.html">
            
                    
                    升级智能合约
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="chap9.html">
            
                <a href="chap9.html">
            
                    
                    智能合约设置背书策略
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="chap10.html">
            
                <a href="chap10.html">
            
                    
                    调试go智能合约
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.5" data-path="chap11.html">
            
                <a href="chap11.html">
            
                    
                    外部构建启动合约
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    SDK实践
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="chap12.html">
            
                <a href="chap12.html">
            
                    
                    基于Java SDK实现合约交易
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >外部构建启动合约</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <p>Fabric2.0&#x7684;&#x91CD;&#x5927;&#x53D8;&#x5316;&#x4E4B;&#x4E00;&#x5C31;&#x662F;&#x652F;&#x6301;&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x667A;&#x80FD;&#x5408;&#x7EA6;&#xFF0C;&#x5728;1.x&#x7248;&#x672C;&#x7684;Fabric&#x4E2D;&#xFF0C;&#x5408;&#x7EA6;&#x662F;&#x7531;Peer&#x4EE5;&#x5BB9;&#x5668;&#x7684;&#x65B9;&#x5F0F;&#x8FDB;&#x884C;&#x542F;&#x52A8;&#x548C;&#x7EF4;&#x62A4;&#xFF0C;&#x4F9D;&#x8D56;&#x4E8E;Docker&#x3002;&#x8FD9;&#x5728;&#x4E00;&#x5B9A;&#x7A0B;&#x5EA6;&#x4E0A;&#x8FDD;&#x53CD;&#x4E86;&#x5B89;&#x5168;&#x51C6;&#x5219;&#xFF0C;&#x5E76;&#x4E14;&#x5728;&#x7BA1;&#x7406;&#x8FD0;&#x7EF4;&#x4E2D;&#x5E26;&#x6765;&#x4E86;&#x9EBB;&#x70E6;&#x3002;Fabric 2.0&#x652F;&#x6301;&#x7528;&#x6237;&#x81EA;&#x884C;&#x542F;&#x52A8;&#x5408;&#x7EA6;&#x5BB9;&#x5668;&#x3002;</p>
<h1 id="1-&#x5408;&#x7EA6;&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x5668;&#x542F;&#x52A8;&#x5668;&#x4ECB;&#x7ECD;">1. &#x5408;&#x7EA6;&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x5668;&#x542F;&#x52A8;&#x5668;&#x4ECB;&#x7ECD;</h1>
<p>&#x8981;&#x5B9E;&#x73B0;&#x4E0D;&#x901A;&#x8FC7;Peer&#x76F4;&#x63A5;&#x6784;&#x5EFA;&#x5408;&#x7EA6;&#xFF0C;&#x9700;&#x8981;&#x9002;&#x7528;&#x7684;&#x5DE5;&#x5177;&#x5C31;&#x662F;&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x5668;&#x548C;&#x542F;&#x52A8;&#x5668;&#xFF0C;&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x5668;&#x548C;&#x542F;&#x52A8;&#x5668;&#x6309;&#x7167;&#x5B98;&#x65B9;&#x7684;&#x8BF4;&#x6CD5;&#x662F;&#x57FA;&#x4E8E;buildpacks&#x5B9E;&#x73B0;&#x5C06;&#x6E90;&#x4EE3;&#x7801;&#x8F6C;&#x5316;&#x6210;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x7684;&#x5DE5;&#x5177;&#x3002;&#x6784;&#x5EFA;&#x5668;&#x8D1F;&#x8D23;&#x51C6;&#x5907;&#x8981;&#x6267;&#x884C;&#x7684;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#xFF0C;&#x542F;&#x52A8;&#x5668;&#x8D1F;&#x8D23;&#x542F;&#x52A8;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#xFF0C;&#x5E76;&#x5B9A;&#x671F;&#x8C03;&#x7528;&#x8FD0;&#x884C;&#x72B6;&#x51B5;&#x68C0;&#x67E5;&#x4EE5;&#x76D1;&#x89C6;&#x542F;&#x52A8;&#x7684;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x6D3B;&#x8DC3;&#x6027;&#x3002;</p>
<h2 id="11-&#x6784;&#x5EFA;&#x5668;&#x4E0E;&#x542F;&#x52A8;&#x5668;&#x7EC4;&#x6210;">1.1 &#x6784;&#x5EFA;&#x5668;&#x4E0E;&#x542F;&#x52A8;&#x5668;&#x7EC4;&#x6210;</h2>
<p>&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x5668;&#x548C;&#x542F;&#x52A8;&#x5668;&#x7531;&#x56DB;&#x4E2A;&#x7A0B;&#x5E8F;&#x6216;&#x811A;&#x672C;&#x7EC4;&#x6210;&#xFF1A;</p>
<pre><code>&#x2022; bin/detect&#xFF1A;&#x786E;&#x5B9A;&#x662F;&#x5426;&#x5E94;&#x4F7F;&#x7528;&#x6B64;buildpack&#x6765;&#x6784;&#x5EFA;chaincode&#x7A0B;&#x5E8F;&#x5305;&#x5E76;&#x542F;&#x52A8;&#x5B83;&#x3002;
&#x2022; bin/build&#xFF1A;&#x5C06;chaincode&#x5305;&#x8F6C;&#x6362;&#x4E3A;&#x53EF;&#x6267;&#x884C;&#x7684;chaincode&#x3002;
&#x2022; bin/release &#xFF08;&#x53EF;&#x9009;&#xFF09;&#xFF1A;&#x5411;peer&#x63D0;&#x4F9B;&#x6709;&#x5173;&#x94FE;&#x7801;&#x7684;&#x5143;&#x6570;&#x636E;&#x3002;
&#x2022; bin/run &#xFF08;&#x53EF;&#x9009;&#xFF09;&#xFF1A;&#x8FD0;&#x884C;&#x94FE;&#x7801;&#x3002;
</code></pre><p>&#x5230;&#x8FD9;&#x91CC;&#x5927;&#x5BB6;&#x4E86;&#x89E3;&#x8FD9;&#x51E0;&#x4E2A;&#x811A;&#x672C;&#x662F;&#x4EC0;&#x4E48;&#x7528;&#x5904;&#x7684;&#x5C31;&#x597D;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x540E;&#x9762;&#x5B9E;&#x8DF5;&#x8FC7;&#x7A0B;&#x4E2D;&#x4F1A;&#x9010;&#x6B65;&#x89E3;&#x91CA;&#x3002;</p>
<h1 id="2-&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x542F;&#x52A8;&#x5408;&#x7EA6;">2 &#x5916;&#x90E8;&#x6784;&#x5EFA;&#x542F;&#x52A8;&#x5408;&#x7EA6;</h1>
<h2 id="21-&#x73AF;&#x5883;&#x51C6;&#x5907;">2.1 &#x73AF;&#x5883;&#x51C6;&#x5907;</h2>
<table>
<thead>
<tr>
<th>&#x7CFB;&#x7EDF;&#x5DE5;&#x5177;</th>
<th>&#x7248;&#x672C;</th>
<th>&#x5907;&#x6CE8;</th>
</tr>
</thead>
<tbody>
<tr>
<td>CentOS</td>
<td>7</td>
</tr>
<tr>
<td>Docker</td>
<td>18.09.4</td>
</tr>
<tr>
<td>Docker-compose</td>
<td>1.23.2</td>
<td>&#x53C2;&#x8003;&#xFF1A;<a href="https://blog.csdn.net/qq_28540443/article/details/104262822" target="_blank">CentOS7&#x5B89;&#x88C5;Docker-compose&#x63A8;&#x8350;&#x65B9;&#x6848;</a></td>
</tr>
<tr>
<td>GO</td>
<td>1.13.4</td>
<td>&#x53C2;&#x8003;&#xFF1A;<a href="https://blog.csdn.net/qq_28540443/article/details/104265094" target="_blank">CentOS7&#x5B89;&#x88C5;Go</a></td>
</tr>
</tbody>
</table>
<h2 id="22-&#x6784;&#x5EFA;&#x5668;&#x542F;&#x52A8;&#x5668;&#x811A;&#x672C;&#x51C6;&#x5907;">2.2 &#x6784;&#x5EFA;&#x5668;&#x542F;&#x52A8;&#x5668;&#x811A;&#x672C;&#x51C6;&#x5907;</h2>
<p>&#x6839;&#x636E;&#x4E0A;&#x9762;&#x5BF9;&#x6784;&#x5EFA;&#x5668;&#x542F;&#x52A8;&#x5668;&#x7684;&#x4ECB;&#x7ECD;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x53EA;&#x9700;&#x8981;&#x521B;&#x5EFA;<code>bin/detect&#x3001;bin/build&#x3001;bin/release</code>&#x4E09;&#x4E2A;&#x811A;&#x672C;&#x3002;</p>
<p>&#x9996;&#x5148;&#x6211;&#x4EEC;&#x5728; ~/first-network &#x4E0B;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;external/bin&#x76EE;&#x5F55;&#x7528;&#x4E8E;&#x5B58;&#x653E;&#x4E0A;&#x9762;&#x4E09;&#x4E2A;&#x811A;&#x672C;</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> ~/first-network
mkdir external &amp;&amp; mkdir external/bin
</code></pre>
<h3 id="221-&#x68C0;&#x6D4B;&#x811A;&#x672C;">2.2.1 &#x68C0;&#x6D4B;&#x811A;&#x672C;</h3>
<p>&#x68C0;&#x6D4B;&#x811A;&#x672C;&#x4E3A;<code>bin/detect</code>,&#x5B83;&#x7528;&#x4E8E;&#x68C0;&#x6D4B;&#x5F53;&#x524D;install&#x7684;&#x5408;&#x7EA6;&#x662F;&#x5426;&#x9002;&#x7528;&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x5668;&#x6784;&#x5EFA;&#xFF0C;&#x5047;&#x5982;<code>exit 0</code>&#x5C31;&#x4F1A;&#x7EE7;&#x7EED;&#x6267;&#x884C;&#x6784;&#x5EFA;&#x53D1;&#x5E03;&#x5916;&#x90E8;&#x5408;&#x7EA6;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;<code>exit 1</code>&#x5C31;&#x4F1A;&#x6309;&#x7167;&#x539F;&#x672C;&#x9002;&#x7528;&#x8282;&#x70B9;&#x5B89;&#x88C5;&#x90E8;&#x7F72;&#x5408;&#x7EA6;&#x7684;&#x65B9;&#x5F0F;&#x3002;</p>
<p>&#x8BE5;&#x811A;&#x672C;&#x662F;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#xFF0C;&#x6211;&#x8FD9;&#x8FB9;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x6A21;&#x677F;</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/sh
</span>
<span class="hljs-comment"># The bin/detect script is responsible for determining whether or not a buildpack</span>
<span class="hljs-comment"># should be used to build a chaincode package and launch it.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># The peer invokes detect with two arguments:</span>
<span class="hljs-comment"># bin/detect CHAINCODE_SOURCE_DIR CHAINCODE_METADATA_DIR</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># When detect is invoked, CHAINCODE_SOURCE_DIR contains the chaincode source and</span>
<span class="hljs-comment"># CHAINCODE_METADATA_DIR contains the metadata.json file from the chaincode package installed to the peer.</span>
<span class="hljs-comment"># The CHAINCODE_SOURCE_DIR and CHAINCODE_METADATA_DIR should be treated as read only inputs.</span>
<span class="hljs-comment"># If the buildpack should be applied to the chaincode source package, detect must return an exit code of 0;</span>
<span class="hljs-comment"># any other exit code will indicate that the buildpack should not be applied.</span>

CHAINCODE_METADATA_DIR=<span class="hljs-string">&quot;<span class="hljs-variable">$2</span>&quot;</span>

<span class="hljs-built_in">set</span> -euo pipefail

<span class="hljs-comment"># use jq to extract the chaincode type from metadata.json and exit with</span>
<span class="hljs-comment"># success if the chaincode type is golang</span>
<span class="hljs-comment"># &#x5224;&#x65AD;&#x76EE;&#x5F55;&#x4E0B;&#x6709;&#x6CA1;&#x6709;metadata.json&#x6587;&#x4EF6; &#x6709;&#x5C31;exit 0 </span>
<span class="hljs-keyword">if</span> [ <span class="hljs-string">&quot;<span class="hljs-variable">$(cat &quot;$CHAINCODE_METADATA_DIR/metadata.json&quot; | sed -e &apos;s/[{}]/&apos;&apos;/g&apos; | awk -F&quot;[,:}]&quot; &apos;{for(i=1;i&lt;=NF;i++)</span>{if(<span class="hljs-variable">$i</span>~/&apos;type&apos;\042/){print <span class="hljs-variable">$(i+1)</span>}}}&apos; | tr -d &apos;&quot;</span><span class="hljs-string">&apos;)&quot; = &quot;external&quot; ]; then
    exit 0
fi

exit 1
</span></code></pre>
<p>&#x8FD9;&#x91CC;&#x8DDF;&#x5B98;&#x65B9;&#x6A21;&#x677F;&#x4E0D;&#x4E00;&#x6837;&#x5728;&#x4E8E;&#xFF0C;&#x9002;&#x7528; <code>sh</code> &#x6267;&#x884C;&#x811A;&#x672C;&#xFF0C;&#x9002;&#x7528;<code>sed</code> &#x66FF;&#x6362;jq&#xFF0C;&#x5C3D;&#x91CF;&#x5C11;&#x5B89;&#x88C5;&#x4E1C;&#x897F;&#x5230;&#x8282;&#x70B9;&#x5BB9;&#x5668;&#x3002;</p>
<h3 id="222-&#x6784;&#x5EFA;&#x811A;&#x672C;">2.2.2 &#x6784;&#x5EFA;&#x811A;&#x672C;</h3>
<p>&#x6784;&#x5EFA;&#x811A;&#x672C;<code>bin/build</code>&#xFF0C;&#x662F;&#x5C06;&#x6211;&#x4EEC;&#x63D0;&#x4EA4;&#x7684;&#x5408;&#x7EA6;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x6309;&#x7167;&#x6784;&#x5EFA;&#x89C4;&#x5219;&#x653E;&#x5230;&#x5B83;&#x6307;&#x5B9A;&#x7684;&#x76EE;&#x5F55;&#x3002;</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/sh
</span>
<span class="hljs-comment"># The bin/build script is responsible for building, compiling, or transforming the contents</span>
<span class="hljs-comment"># of a chaincode package into artifacts that can be used by release and run.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># The peer invokes build with three arguments:</span>
<span class="hljs-comment"># bin/build CHAINCODE_SOURCE_DIR CHAINCODE_METADATA_DIR BUILD_OUTPUT_DIR</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># When build is invoked, CHAINCODE_SOURCE_DIR contains the chaincode source and</span>
<span class="hljs-comment"># CHAINCODE_METADATA_DIR contains the metadata.json file from the chaincode package installed to the peer.</span>
<span class="hljs-comment"># BUILD_OUTPUT_DIR is the directory where build must place artifacts needed by release and run.</span>
<span class="hljs-comment"># The build script should treat the input directories CHAINCODE_SOURCE_DIR and</span>
<span class="hljs-comment"># CHAINCODE_METADATA_DIR as read only, but the BUILD_OUTPUT_DIR is writeable.</span>

CHAINCODE_SOURCE_DIR=<span class="hljs-string">&quot;<span class="hljs-variable">$1</span>&quot;</span>
CHAINCODE_METADATA_DIR=<span class="hljs-string">&quot;<span class="hljs-variable">$2</span>&quot;</span>
BUILD_OUTPUT_DIR=<span class="hljs-string">&quot;<span class="hljs-variable">$3</span>&quot;</span>

<span class="hljs-built_in">set</span> -euo pipefail

<span class="hljs-comment">#external chaincodes expect connection.json file in the chaincode package</span>
<span class="hljs-keyword">if</span> [ ! <span class="hljs-_">-f</span> <span class="hljs-string">&quot;<span class="hljs-variable">$CHAINCODE_SOURCE_DIR</span>/connection.json&quot;</span> ]; <span class="hljs-keyword">then</span>
    &gt;&amp;2 <span class="hljs-built_in">echo</span> <span class="hljs-string">&quot;<span class="hljs-variable">$CHAINCODE_SOURCE_DIR</span>/connection.json not found&quot;</span>
    <span class="hljs-built_in">exit</span> 1
<span class="hljs-keyword">fi</span>

<span class="hljs-comment">#simply copy the endpoint information to specified output location</span>
cp <span class="hljs-variable">$CHAINCODE_SOURCE_DIR</span>/connection.json <span class="hljs-variable">$BUILD_OUTPUT_DIR</span>/connection.json

<span class="hljs-keyword">if</span> [ <span class="hljs-_">-d</span> <span class="hljs-string">&quot;<span class="hljs-variable">$CHAINCODE_SOURCE_DIR</span>/metadata&quot;</span> ]; <span class="hljs-keyword">then</span>
    cp <span class="hljs-_">-a</span> <span class="hljs-variable">$CHAINCODE_SOURCE_DIR</span>/metadata <span class="hljs-variable">$BUILD_OUTPUT_DIR</span>/metadata
<span class="hljs-keyword">fi</span>

<span class="hljs-built_in">exit</span> 0
</code></pre>
<h3 id="223-&#x53D1;&#x5E03;&#x811A;&#x672C;">2.2.3 &#x53D1;&#x5E03;&#x811A;&#x672C;</h3>
<p>&#x5728;&#x5B8C;&#x6210;&#x5408;&#x7EA6;&#x57FA;&#x7840;&#x6784;&#x5EFA;&#x4E4B;&#x540E;&#xFF0C;&#x5269;&#x4E0B;&#x53EA;&#x9700;&#x8981;&#x53D1;&#x5E03;&#x5C31;&#x884C;&#x3002;
&#x53D1;&#x5E03;&#x811A;&#x672C;&#x662F;<code>bin/release</code></p>
<h2 id="23-&#x4FEE;&#x6539;&#x8282;&#x70B9;&#x914D;&#x7F6E;">2.3 &#x4FEE;&#x6539;&#x8282;&#x70B9;&#x914D;&#x7F6E;</h2>
<h3 id="231-coreyaml">2.3.1 core.yaml</h3>
<p><code>core.yaml</code>&#x6587;&#x4EF6;&#x6709;&#x7684;&#x670B;&#x53CB;&#x53EF;&#x80FD;&#x4E0D;&#x592A;&#x719F;&#x6089;&#xFF0C;&#x8FD8;&#x662F;&#x7B80;&#x5355;&#x79D1;&#x666E;&#x4E00;&#x4E0B;&#xFF0C;core.yaml&#x662F;&#x8282;&#x70B9;&#x7684;&#x9ED8;&#x8BA4;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x8BE6;&#x7EC6;&#x7684;&#x914D;&#x7F6E;&#x9879;&#x53EF;&#x4EE5;&#x5728;&#x6E90;&#x7801;<code>~/fabric/sample-config/core.yaml</code>&#x91CC;&#x9762;&#x627E;&#x5230;&#xFF0C;&#x4E00;&#x822C;&#x6765;&#x8BF4;&#xFF0C;&#x5047;&#x5982;&#x6211;&#x4EEC;&#x6CA1;&#x6709;&#x5B9A;&#x4E49;core.yaml&#xFF0C;&#x8282;&#x70B9;&#x5185;&#x90E8;/etc/hyperledger&#x76EE;&#x5F55;&#x4E0B;&#x4E5F;&#x4F1A;&#x6709;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x4ED6;&#x7684;&#x53C2;&#x6570;&#x8DDF;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x662F;&#x57FA;&#x672C;&#x4E00;&#x81F4;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x7684;&#x4F18;&#x5148;&#x7EA7;&#x522B;&#x9AD8;&#x4E8E;<code>core.yam</code>,&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x8BBE;&#x7F6E;&#x7684;&#x53C2;&#x6570;&#x7531;&#x4E8E;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#x5BF9;&#x8C61;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x521B;&#x5EFA;core.yaml&#x5E76;&#x4E14;&#x5C06;<code>core.yaml</code>&#x6620;&#x5C04;&#x5230;&#x8282;&#x70B9;&#x7684;<code>/etc/hyperledger/fabric</code>&#x76EE;&#x5F55;&#x4E0B;&#x9762;&#x3002;</p>
<p>&#x5177;&#x4F53;&#x64CD;&#x4F5C;&#x5982;&#x4E0B;&#xFF1A;</p>
<ol>
<li>&#x590D;&#x5236;sample-config&#x76EE;&#x5F55;&#x4E0B;&#x7684;core.yaml&#x5230;~first-network</li>
</ol>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> ~/first-network
cp ../../sample-config/core.yaml .
</code></pre>
<p>2.&#x4FEE;&#x6539;core.yaml&#x5408;&#x7EA6;&#x76F8;&#x5173;&#x914D;&#x7F6E;</p>
<p>&#x5B9A;&#x4F4D;<code>:524</code>&#x884C;</p>
<pre><code class="lang-bash">    externalBuilders:
         - path: /opt/gopath/src/github.com/hyperledger/fabric/peer/external
           name: builder
        <span class="hljs-comment">#   environmentWhitelist:</span>
        <span class="hljs-comment">#      - ENVVAR_NAME_TO_PROPAGATE_FROM_PEER</span>
        <span class="hljs-comment">#      - GOPROXY</span>
</code></pre>
<p><code>path</code>: externalBuilders&#x8DEF;&#x5F84; ,&#x586B;&#x5199;&#x8282;&#x70B9;&#x5BB9;&#x5668;&#x5185;&#x5B58;&#x653E;externalBuilder&#x811A;&#x672C;(1.2.2&#x5199;&#x7684;3&#x4E2A;&#x811A;&#x672C;)&#x7684;&#x76EE;&#x5F55;&#xFF0C;&#x76EE;&#x524D;&#x5B9A;&#x4E49;&#x5728;&#x8282;&#x70B9;&#x5185;&#x90E8;&#x7684;/opt/gopath/src/github.com/hyperledger/fabric/peer/external&#xFF0C;&#x5404;&#x4F4D;&#x53EF;&#x81EA;&#x5B9A;&#x4E49;&#x8DEF;&#x5F84;&#xFF0C;&#x540E;&#x9762;&#x6620;&#x5C04;&#x3002;</p>
<p> <code>name:</code> &#x5916;&#x90E8;&#x6784;&#x5EFA;&#x5668;&#x540D;&#x79F0;&#xFF0C;&#x81EA;&#x5B9A;&#x4E49;&#x3002;</p>
<p><code>environmentWhitelist:</code>&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x767D;&#x540D;&#x5355;&#xFF0C;&#x8282;&#x70B9;&#x5728;&#x8C03;&#x7528;&#x6784;&#x5EFA;&#x5668;&#x811A;&#x672C;&#x7684;&#x65F6;&#x5019;&#x53EF;&#x4EE5;&#x91C7;&#x7528;&#x7684;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x3002;</p>
<p>&#x7136;&#x540E;&#x4FDD;&#x5B58;&#x6587;&#x4EF6;&#x5C31;&#x884C;&#x4E86;&#x3002;</p>
<h3 id="232-&#x8282;&#x70B9;&#x5BB9;&#x5668;&#x914D;&#x7F6E;">2.3.2 &#x8282;&#x70B9;&#x5BB9;&#x5668;&#x914D;&#x7F6E;</h3>
<p>&#x8282;&#x70B9;&#x5BB9;&#x5668;&#x914D;&#x7F6E;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x5B8C;&#x6210;2&#x4E2A;&#x4E8B;&#x60C5;&#xFF0C;&#x628A;external&#x7684;3&#x4E2A;&#x811A;&#x672C;&#x6620;&#x5C04;&#x5230;externalBuilders.path&#x4EE5;&#x53CA;&#x5C06;core.yaml&#x6302;&#x8F7D;&#x5230;&#x5BB9;&#x5668;&#x7684;/etc/hyperledger/fabric&#x76EE;&#x5F55;</p>
<p>&#x4EE5;first-network&#x7684;&#x914D;&#x7F6E;&#x4E3A;&#x4F8B;</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> ~/first-network
vi base/peer-base.yaml
</code></pre>
<p>&#x7F16;&#x8F91;peer-base&#x670D;&#x52A1;&#x7684;&#x6302;&#x8F7D;&#x53C2;&#x6570;</p>
<pre><code class="lang-bash">services:
  peer-base:
    image: hyperledger/fabric-peer:<span class="hljs-variable">$IMAGE_TAG</span>
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      <span class="hljs-comment"># the following setting starts chaincode containers on the same</span>
      <span class="hljs-comment"># bridge network as the peers</span>
      <span class="hljs-comment"># https://docs.docker.com/compose/networking/</span>
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=<span class="hljs-variable">${COMPOSE_PROJECT_NAME}</span>_byfn
      - FABRIC_LOGGING_SPEC=INFO
      <span class="hljs-comment">#- FABRIC_LOGGING_SPEC=DEBUG</span>
      - CORE_PEER_TLS_ENABLED=<span class="hljs-literal">true</span>
      - CORE_PEER_GOSSIP_USELEADERELECTION=<span class="hljs-literal">true</span>
      - CORE_PEER_GOSSIP_ORGLEADER=<span class="hljs-literal">false</span>
      - CORE_PEER_PROFILE_ENABLED=<span class="hljs-literal">true</span>
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      <span class="hljs-comment"># Allow more time for chaincode container to build on install.</span>
      - CORE_CHAINCODE_EXECUTETIMEOUT=300s
      <span class="hljs-comment">#&#x6302;&#x8F7D;&#x5916;&#x90E8;&#x542F;&#x52A8;&#x667A;&#x80FD;&#x5408;&#x7EA6;&#x76F8;&#x5173;&#x811A;&#x672C;&#x6587;&#x4EF6;&#x4EE5;&#x53CA;core.yaml</span>
    volumes:
      <span class="hljs-comment"># &#x6302;&#x8F7D;&#x76EE;&#x5F55;</span>
      - ../external:/opt/gopath/src/github.com/hyperledger/fabric/peer/external
      - ../core.yaml:/etc/hyperledger/fabric/core.yaml
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    <span class="hljs-built_in">command</span>: peer node start
</code></pre>
<p>&#x7136;&#x540E;&#x5C31;&#x53EF;&#x4EE5;&#x5FEB;&#x4E50;&#x5730;&#x9002;&#x7528;<code>./byfn.sh up</code>&#x542F;&#x52A8;&#x7F51;&#x7EDC;&#x4E86;~,&#x5177;&#x4F53;&#x53EF;&#x53C2;&#x8003;<a href="https://blog.csdn.net/qq_28540443/article/details/104265844" target="_blank">(&#x4E00;)HyperLedger Fabric 2.0-release&#x7F16;&#x8BD1;&#x955C;&#x50CF;&#x4E8C;&#x8FDB;&#x5236;&#x6587;&#x4EF6;+&#x6D4B;&#x8BD5;&#x7F51;&#x7EDC;&#x90E8;&#x7F72;</a>&#x3002;</p>
<h2 id="24-&#x90E8;&#x7F72;&#x5408;&#x7EA6;&#x5230;&#x7F51;&#x7EDC;">2.4 &#x90E8;&#x7F72;&#x5408;&#x7EA6;&#x5230;&#x7F51;&#x7EDC;</h2>
<p>&#x8981;&#x5B9E;&#x73B0;&#x5916;&#x90E8;&#x90E8;&#x7F72;&#x5408;&#x7EA6;&#xFF0C;&#x5BF9;&#x4E8E;&#x8981;install&#x5230;fabric&#x7684;&#x5408;&#x7EA6;&#x5305;&#x8DDF;&#x4E4B;&#x524D;<a href="https://blog.csdn.net/qq_28540443/article/details/104318163" target="_blank">(&#x4E94;)Fabric2.0 &#x667A;&#x80FD;&#x5408;&#x7EA6;&#x5B9E;&#x8DF5;- &#x5B89;&#x88C5;&#x4EE5;&#x53CA;&#x5B9A;&#x4E49;&#x667A;&#x80FD;&#x5408;&#x7EA6;</a>&#x7684;&#x5305;&#x662F;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x8FD9;&#x4E2A;&#x5305;&#x91CC;&#x9762;&#x4E0D;&#x9700;&#x8981;&#x5408;&#x7EA6;&#x7684;&#x6E90;&#x4EE3;&#x7801;&#x3002;</p>
<p>&#x6309;&#x7167;&#x5B9A;&#x4E49;&#x6765;&#x8BF4;&#xFF0C;&#x8FD9;&#x4E2A;&#x5408;&#x7EA6;&#x5305;&#x542B;&#x6709;&#xFF1A;</p>
<blockquote>
<p> metadata.json &#xFF1A; &#x5408;&#x7EA6;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x4E0E;&#x539F;&#x672C;&#x7684;&#x5408;&#x7EA6;&#x5C5E;&#x6027;&#x4E0D;&#x4E00;&#x81F4;&#x7684;&#x662F;&#x4ED6;&#x7684;path&#x53EF;&#x4EE5;&#x4E3A;&#x7A7A;&#xFF0C;&#x4ED6;&#x7684;type&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#x3002;</p>
<p>connection.json :&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x662F;&#x7528;&#x4E8E;&#x8282;&#x70B9;&#x53BB;&#x8FDE;&#x63A5;&#x5408;&#x7EA6;&#x7684;&#x76F8;&#x5173;&#x914D;&#x7F6E;&#x4FE1;&#x606F;&#xFF0C;&#x53CC;&#x65B9;&#x4EA4;&#x4E92;&#x57FA;&#x4E8E;grpc&#x670D;&#x52A1;&#x3002;</p>
<p>metadata&#x6587;&#x4EF6;&#x5939;&#xFF1A;&#x5E94;&#x8BE5;&#x662F;&#x8DDF;couchdb&#x5B58;&#x653E;&#x79C1;&#x6709;&#x6570;&#x636E;&#x76F8;&#x5173;&#x7684;&#xFF0C;&#x672C;&#x5B9E;&#x8DF5;&#x4E0D;&#x505A;&#x8BE6;&#x7EC6;&#x8BF4;&#x660E;&#x3002;</p>
</blockquote>
<p>&#x6839;&#x636E;&#x6211;&#x8FD9;&#x8FB9;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x76EE;&#x524D;&#x53EA;&#x9700;&#x8981;&#x6709;metadata.json&#x8DDF;connection.json&#x5C31;&#x884C;&#x4E86;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x5728; ~/fabric-samples/chaincode/abstore/go &#x4E0B;&#x9762;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;packing&#x76EE;&#x5F55;&#x7528;&#x4E8E;&#x5B58;&#x653E;&#x6253;&#x5305;&#x6587;&#x4EF6;</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> ~/fabric-samples/chaincode/abstore/go &amp;&amp; mkdir packing &amp;&amp; <span class="hljs-built_in">cd</span> packing
</code></pre>
<h3 id="241-&#x7F16;&#x5199;metadatajson">2.4.1 &#x7F16;&#x5199;metadata.json</h3>
<p>&#x5728;packing&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x7F16;&#x8F91;metadata.json&#x6587;&#x4EF6;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-bash">{<span class="hljs-string">&quot;path&quot;</span>:<span class="hljs-string">&quot;&quot;</span>,<span class="hljs-string">&quot;type&quot;</span>:<span class="hljs-string">&quot;external&quot;</span>,<span class="hljs-string">&quot;label&quot;</span>:<span class="hljs-string">&quot;mycc2&quot;</span>}
</code></pre>
<p>path: &#x4E0D;&#x9700;&#x8981;&#x586B;&#x5199;&#x5185;&#x5BB9;&#x3002;
type: &#x81EA;&#x5B9A;&#x4E49;&#xFF0C;&#x7528;&#x4E8E;<code>bin/detect</code>&#x68C0;&#x6D4B;&#x3002;
label: &#x81EA;&#x5B9A;&#x4E49;&#x3002;</p>
<h3 id="242-&#x7F16;&#x5199;connectionjson">2.4.2 &#x7F16;&#x5199;connection.json</h3>
<p>&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-bash">{
    <span class="hljs-string">&quot;address&quot;</span>: <span class="hljs-string">&quot;192.168.2.103:7052&quot;</span>,
    <span class="hljs-string">&quot;dial_timeout&quot;</span>: <span class="hljs-string">&quot;10s&quot;</span>,
    <span class="hljs-string">&quot;tls_required&quot;</span>: <span class="hljs-literal">false</span>,
    <span class="hljs-string">&quot;client_auth_required&quot;</span>: <span class="hljs-literal">false</span>,
    <span class="hljs-string">&quot;client_key&quot;</span>: <span class="hljs-string">&quot;-----BEGIN EC PRIVATE KEY----- ... -----END EC PRIVATE KEY-----&quot;</span>,
    <span class="hljs-string">&quot;client_cert&quot;</span>: <span class="hljs-string">&quot;-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----&quot;</span>,
    <span class="hljs-string">&quot;root_cert&quot;</span>: <span class="hljs-string">&quot;-----BEGIN CERTIFICATE---- ... -----END CERTIFICATE-----&quot;</span>
}
</code></pre>
<p><code>address</code>:  &#x6211;&#x4EEC;&#x5C06;&#x8981;&#x5728;&#x5916;&#x9762;&#x8FD0;&#x884C;/&#x90E8;&#x7F72;&#x7684;&#x5408;&#x7EA6;&#x5F00;&#x51FA;&#x6765;&#x7684;grpc&#x670D;&#x52A1;ip&#x8DDF;&#x7AEF;&#x53E3;&#xFF0C;&#x6700;&#x597D;&#x5148;&#x5B9A;&#x4E0B;&#x6765;(&#x6CA1;&#x5B9A;&#x597D;&#x968F;&#x4FBF;&#x5199;&#x4E2A;&#x4E5F;&#x884C;&#xFF0C;&#x53CD;&#x6B63;&#x540E;&#x9762;&#x4E00;&#x4E2A;&#x4E2A;&#x8282;&#x70B9;&#x6539;&#x5C31;&#x662F;&#x4E86;)&#x3002;</p>
<p><code>dial_timeout</code>:grpc&#x8FDE;&#x63A5;&#x8D85;&#x65F6;&#x65F6;&#x95F4;&#x3002;&#x6307;&#x5B9A;&#x4E3A;&#x5177;&#x6709;&#x65F6;&#x95F4;&#x5355;&#x4F4D;&#xFF08;&#x4F8B;&#x5982;&#x201C; 10s&#x201D;&#xFF0C;&#x201C; 500ms&#x201D;&#xFF0C;&#x201C; 1m&#x201D;&#xFF09;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x3002;&#x5982;&#x679C;&#x672A;&#x6307;&#x5B9A;&#xFF0C;&#x9ED8;&#x8BA4;&#x503C;&#x4E3A;&#x201C; 3s&#x201D;&#x3002;</p>
<p><code>tls_required</code>: &#x662F;&#x5426;&#x9700;&#x8981;tls&#xFF0C;&#x89C6;&#x4E4E;&#x60A8;&#x7B49;&#x4F1A;&#x5728;&#x5408;&#x7EA6;&#x4E0A;&#x9762;&#x7F16;&#x8F91;&#x7684;grpc&#x670D;&#x52A1;&#x7AEF;&#x662F;&#x5426;&#x9700;&#x8981;&#x8BC1;&#x4E66;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x5C31;false&#xFF0C;&#x9700;&#x8981;true&#x3002;&#x5047;&#x5982;false&#x7684;&#x8BDD;&#xFF0C;&#x4E0B;&#x9762;3&#x9879;&#x53EF;&#x4EE5;&#x5C31;&#x8FD9;&#x6837;&#x6309;&#x6A21;&#x677F;&#x586B;&#x5199;&#xFF0C;&#x5199;&#x7A7A;&#x4E5F;&#x884C;&#x3002;</p>
<p><code>client_key</code>: grpc &#x5BA2;&#x6237;&#x7AEF;&#x8BBF;&#x95EE;&#x5408;&#x7EA6;&#x670D;&#x52A1;&#x7AEF;&#x9700;&#x8981;&#x7684;&#x79C1;&#x94A5;&#x3002;</p>
<p><code>client_cert</code>: grpc &#x5BA2;&#x6237;&#x7AEF;&#x8BBF;&#x95EE;&#x5408;&#x7EA6;&#x670D;&#x52A1;&#x7AEF;&#x9700;&#x8981;&#x7684;&#x8BC1;&#x4E66;&#x3002;</p>
<p><code>root_cert</code>: grpc &#x5BA2;&#x6237;&#x7AEF;&#x8BBF;&#x95EE;&#x5408;&#x7EA6;&#x670D;&#x52A1;&#x7AEF;&#x9700;&#x8981;&#x7684;&#x6839;&#x8BC1;&#x4E66;&#x3002;</p>
<h3 id="242-&#x6253;&#x5305;&#x5408;&#x7EA6;">2.4.2 &#x6253;&#x5305;&#x5408;&#x7EA6;</h3>
<p>&#x8FD8;&#x662F;&#x5728;packing&#x76EE;&#x5F55;
&#x6267;&#x884C;&#x4E00;&#x4E0B;&#x547D;&#x4EE4;&#xFF1A;</p>
<pre><code class="lang-bash"> tar cfz code.tar.gz connection.json  
 tar cfz mycc2.tgz metadata.json code.tar.gz
</code></pre>
<p>&#x67E5;&#x770B;&#x5F53;&#x524D;packing&#x76EE;&#x5F55;
<img src="https://img-blog.csdnimg.cn/20200311145537953.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<h3 id="243-&#x5B89;&#x88C5;&#x90E8;&#x7F72;&#x5408;&#x7EA6;">2.4.3 &#x5B89;&#x88C5;&#x90E8;&#x7F72;&#x5408;&#x7EA6;</h3>
<p>&#x6574;&#x4E2A;2.4.3&#x64CD;&#x4F5C;&#x901A;&#x8FC7;cli&#x64CD;&#x4F5C;</p>
<pre><code class="lang-bash">docker <span class="hljs-built_in">exec</span> -it cli bash 
<span class="hljs-built_in">cd</span> ../../fabric-samples/chaincode/abstore/packing
</code></pre>
<p>&#x540E;&#x9762;&#x4ECE;install&#x5F00;&#x59CB;&#x5230;commit&#x5B8C;&#x6210;&#x5408;&#x7EA6;&#x5B89;&#x88C5;&#x90E8;&#x7F72;&#xFF0C;&#x8DDF;&#x5E73;&#x5E38;&#x6CA1;&#x4EC0;&#x4E48;&#x4E0D;&#x4E00;&#x6837;</p>
<p>&#x4E0B;&#x9762;&#x547D;&#x4EE4;&#x81EA;&#x884C;&#x66FF;&#x6362;&#x53C2;&#x6570;&#xFF0C;&#x5177;&#x4F53;&#x53C2;&#x8003;<a href="https://blog.csdn.net/qq_28540443/article/details/104318163" target="_blank">(&#x4E94;)Fabric2.0 &#x667A;&#x80FD;&#x5408;&#x7EA6;&#x5B9E;&#x8DF5;- &#x5B89;&#x88C5;&#x4EE5;&#x53CA;&#x5B9A;&#x4E49;&#x667A;&#x80FD;&#x5408;&#x7EA6;</a></p>
<p>install&#x5408;&#x7EA6;&#xFF0C;&#x6BCF;&#x4E2A;&#x80CC;&#x4E66;&#x8282;&#x70B9;&#x90FD;&#x8981;install</p>
<pre><code class="lang-bash">peer lifecycle chaincode install mycc2.tgz
</code></pre>
<p>&#x6279;&#x51C6;&#x5408;&#x7EA6;&#x5B9A;&#x4E49;&#xFF0C;&#x5FC5;&#x987B;&#x7B26;&#x5408;lifecycle&#x7B56;&#x7565;</p>
<pre><code class="lang-bash">peer lifecycle chaincode approveformyorg --tls <span class="hljs-literal">true</span> --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name mycc2 --version 1 --init-required --package-id mycc_1:84b3aaf583a6632e806a0ff46ad804539797d84ff7826c88a6d6009a9930cfee --sequence 1 --waitForEvent
</code></pre>
<p>&#x63D0;&#x4EA4;&#x5408;&#x7EA6;&#x5B9A;&#x4E49;&#x5230;&#x7F51;&#x7EDC;</p>
<pre><code class="lang-bash"> peer lifecycle chaincode commit -o orderer.example.com:7050 --tls <span class="hljs-literal">true</span> --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --version 1 --sequence 1  --init-required
</code></pre>
<p>&#x5B8C;&#x5168;&#x90E8;&#x7F72;&#x6210;&#x529F;&#x4E4B;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x8DDF;&#x5F80;&#x5E38;&#x90E8;&#x7F72;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#x662F;&#xFF0C;&#x5408;&#x7EA6;&#x5BB9;&#x5668;&#x5E76;&#x6CA1;&#x6709;&#x542F;&#x52A8;&#xFF0C;&#x5728;&#x8282;&#x70B9;&#x5BB9;&#x5668;
<code>/var/hyperledger/production/externalbuilder/builds/</code>&#x51FA;&#x73B0;&#x6784;&#x5EFA;&#x53D1;&#x5E03;&#x540E;&#x7684;&#x5408;&#x7EA6;&#x6587;&#x4EF6;&#x76EE;&#x5F55;:</p>
<p><img src="https://img-blog.csdnimg.cn/2020031115154175.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<h4 id="2431-&#x53EF;&#x80FD;&#x51FA;&#x73B0;&#x7684;&#x9519;&#x8BEF;&#x4E0E;&#x89E3;&#x51B3;&#x65B9;&#x6848;">2.4.3.1 &#x53EF;&#x80FD;&#x51FA;&#x73B0;&#x7684;&#x9519;&#x8BEF;&#x4E0E;&#x89E3;&#x51B3;&#x65B9;&#x6848;</h4>
<p><code>could not build chaincode :docker build failed: platform builder failed: Failed to generatea Dockerfile:Unknow Chaincode Type:EXTERNAL</code>
<img src="https://img-blog.csdnimg.cn/20200311150123140.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;">
&#x9996;&#x5148;&#x9519;&#x8BEF;&#x7684;&#x610F;&#x601D;&#x5C31;&#x60A8;install&#x7684;&#x5408;&#x7EA6;&#x7C7B;&#x578B;&#x4E0D;&#x5BF9;&#xFF0C;&#x5408;&#x7EA6;&#x7C7B;&#x578B;&#x5B9A;&#x4E49;&#x662F;&#x5728;&#x6211;&#x4EEC;&#x524D;&#x9762;&#x5B9A;&#x4E49;&#x7684;metadata.json&#x91CC;&#x9762;&#x7684;type&#xFF0C;&#x6211;&#x4EEC;&#x4E3A;&#x4E86;&#x533A;&#x4EFD;&#x539F;&#x672C;&#x7684;&#x90E8;&#x7F72;&#x5408;&#x7EA6;&#x65B9;&#x5F0F;&#x586B;&#x5199;&#x4E86;external&#xFF0C;&#x4E00;&#x4E2A;&#x4E0D;&#x5C5E;&#x4E8E;fabric&#x652F;&#x6301;&#x7684;&#x5408;&#x7EA6;&#x7C7B;&#x578B;&#x7684;type&#x3002;</p>
<p>&#x90A3;&#x662F;&#x4E0D;&#x662F;&#x8BF4;&#x660E;&#x6211;&#x4EEC;&#x9519;&#x4E86;&#xFF1F;</p>
<p>&#x662F;&#x7684;&#x3002;</p>
<p>&#x4F46;&#x662F;&#x9519;&#x7684;&#x5730;&#x65B9;&#x5728;&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x5668;&#x542F;&#x52A8;&#x5668;&#x7684;&#x811A;&#x672C;&#xFF0C;&#x5E76;&#x4E0D;&#x662F;&#x5408;&#x7EA6;&#x5B9A;&#x4E49;metadata.json&#x3002;&#x5FC5;&#x987B;&#x8BA9;&#x4F60;&#x7684;bin/detect,bin/build,bin/release&#x811A;&#x672C;&#x662F;&#x80FD;&#x6B63;&#x5E38;&#x6267;&#x884C;&#xFF0C;&#x6BD4;&#x5982;&#x8BF4;&#x8282;&#x70B9;&#x5BB9;&#x5668;&#x6CA1;&#x6709;jq&#x5305;&#xFF0C;&#x4F46;&#x662F;&#x5B98;&#x65B9;&#x6848;&#x4F8B;&#x91CC;&#x9762;&#x662F;&#x4F7F;&#x7528;jq&#x89E3;&#x6790;&#x914D;&#x7F6E;&#xFF0C;&#x8FD9;&#x662F;detect&#x6267;&#x884C;&#x5C31;&#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x5728;&#x62A5;&#x9519;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x4F1A;&#x76F4;&#x63A5;&#x9009;&#x62E9;&#x539F;&#x672C;&#x7684;&#x5408;&#x7EA6;&#x90E8;&#x7F72;&#x65B9;&#x5F0F;&#x3002;&#x5F53;&#x7136;&#x6309;&#x7167;&#x6211;&#x4E0A;&#x9762;&#x7ED9;&#x7684;&#x811A;&#x672C;&#x662F;&#x4E0D;&#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x5927;&#x5BB6;&#x5927;&#x80C6;install&#x3002;</p>
<h3 id="244-&#x7F16;&#x5199;&#x5408;&#x7EA6;">2.4.4 &#x7F16;&#x5199;&#x5408;&#x7EA6;</h3>
<p>&#x8FD9;&#x4E00;&#x6B21;&#x987A;&#x5E8F;&#x8DDF;&#x4E4B;&#x524D;&#x4E0D;&#x4E00;&#x6837;&#xFF0C;&#x4F46;&#x662F;&#x5176;&#x5B9E;&#x4E5F;&#x662F;&#x53EF;&#x4EE5;&#x4E00;&#x5F00;&#x59CB;&#x7F16;&#x5199;&#x7684;&#xFF0C;&#x95EE;&#x9898;&#x4E0D;&#x5927;&#x3002;</p>
<p>&#x4EE5;abstore&#x5408;&#x7EA6;&#x4F8B;&#x5B50;&#x4E3A;&#x4F8B;&#xFF0C;&#x53EA;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x539F;&#x6709;&#x7684;main&#x65B9;&#x6CD5;&#xFF0C;&#x7EE7;&#x627F;shim.ChaincodeServer</p>
<pre><code class="lang-bash">func <span class="hljs-function"><span class="hljs-title">main</span></span>() {

        server := &amp;shim.ChaincodeServer{
                CCID:    os.Getenv(<span class="hljs-string">&quot;CHAINCODE_CCID&quot;</span>),
                Address: os.Getenv(<span class="hljs-string">&quot;CHAINCODE_ADDRESS&quot;</span>),
                CC:      new(ABstore),
                TLSProps: shim.TLSProperties{
                                Disabled: <span class="hljs-literal">true</span>,
                },
        }

        // Start the chaincode external server
        err := server.Start()

        <span class="hljs-keyword">if</span> err != nil {
                fmt.Printf(<span class="hljs-string">&quot;Error starting Marbles02 chaincode: %s&quot;</span>, err)
        }
}
</code></pre>
<p><code>CCID</code> &#xFF1A; &#x90E8;&#x7F72;&#x5B8C;&#x6210;&#x540E;&#x751F;&#x4EA7;&#x7684;&#x5408;&#x7EA6;ID&#xFF0C;&#x8FD9;&#x91CC;&#x4F7F;&#x7528;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x8BFB;&#x53D6;&#x6BD4;&#x8F83;&#x65B9;&#x4FBF;&#xFF0C;&#x5982; 
mycc2:6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454</p>
<p><code>Address</code>:&#x5B9A;&#x4E49;grpc&#x670D;&#x52A1;IP&#x7AEF;&#x53E3;&#xFF0C;&#x5982; 0.0.0.0:9999&#xFF0C;&#x8FD9;&#x91CC;&#x4F7F;&#x7528;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x8BFB;&#x53D6;&#x6BD4;&#x8F83;&#x65B9;&#x4FBF;&#x3002;</p>
<p><code>CC</code>: &#x5408;&#x7EA6;&#x5BF9;&#x8C61;&#x3002;</p>
<p><code>TLSProps</code>: tls&#x914D;&#x7F6E;&#xFF0C;&#x4E0E;connection.json&#x76F8;&#x547C;&#x5E94;&#x3002;</p>
<h3 id="245-&#x542F;&#x52A8;&#x5408;&#x7EA6;">2.4.5 &#x542F;&#x52A8;&#x5408;&#x7EA6;</h3>
<p><code>&#x6574;&#x4E2A;2.4.5&#x64CD;&#x4F5C;&#x90FD;&#x5728;&#x5BBF;&#x4E3B;&#x673A;</code></p>
<p>&#x5176;&#x5B9E;&#x5230;&#x8FD9;&#x91CC;&#xFF0C;&#x542F;&#x52A8;&#x5408;&#x7EA6;&#x53EF;&#x4EE5;&#x9009;&#x5F88;&#x591A;&#x79CD;&#x65B9;&#x5F0F;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x7F16;&#x8F91;&#x5668;&#x542F;&#x52A8;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;go build&#x4E00;&#x4E0B;&#x4E8C;&#x8FDB;&#x5236;&#x542F;&#x52A8;&#xFF0C;&#x8FD9;&#x91CC;&#x7684;&#x8BDD;&#xFF0C;&#x5BF9;&#x4E8E;&#x6D4B;&#x8BD5;/&#x751F;&#x4EA7;&#x73AF;&#x5883;&#xFF0C;&#x6211;&#x5E0C;&#x671B;&#x8FD9;&#x4E2A;chaincode&#x66F4;&#x52A0;&#x65B9;&#x4FBF;&#x8FC1;&#x79FB;&#x73AF;&#x5883;(&#x6240;&#x4EE5;&#x4E0A;&#x9762;&#x8BFB;&#x53D6;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x4E5F;&#x662F;&#x4E3A;&#x6B64;)&#xFF0C;&#x6211;&#x4F1A;&#x9009;&#x62E9;&#x6253;&#x5305;&#x5408;&#x7EA6;&#x955C;&#x50CF;&#xFF0C;&#x8FD0;&#x884C;&#x5408;&#x7EA6;&#x5BB9;&#x5668;&#xFF0C;&#x5F53;&#x7136;&#x4E00;&#x822C;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x8C03;&#x8BD5;&#x53EF;&#x4EE5;IDE&#x6765;&#x5F04;&#xFF0C;&#x4F46;&#x662F;&#x6D4B;&#x8BD5;&#x751F;&#x4EA7;&#x73AF;&#x5883;&#x76EE;&#x524D;&#x8FD8;&#x662F;&#x504F;&#x5411;docker&#x3002;</p>
<p>&#x56E0;&#x6B64;&#x6211;&#x4EEC;&#x63A5;&#x4E0B;&#x6765;&#x6309;&#x7167;&#x4E00;&#x822C;&#x7684;&#x5BB9;&#x5668;&#x6784;&#x5EFA;&#xFF0C;&#x6765;&#x6784;&#x5EFA;&#x6211;&#x4EEC;&#x7684;&#x5408;&#x7EA6;&#x955C;&#x50CF;&#x4EE5;&#x53CA;&#x542F;&#x52A8;&#x5408;&#x7EA6;&#x5BB9;&#x5668;</p>
<h4 id="2451--&#x6784;&#x5EFA;&#x5408;&#x7EA6;&#x955C;&#x50CF;">2.4.5.1  &#x6784;&#x5EFA;&#x5408;&#x7EA6;&#x955C;&#x50CF;</h4>
<p>&#x5728;abstore/go &#x76EE;&#x5F55;&#xFF0C;&#x7F16;&#x8F91;Dockerfile&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-bash"><span class="hljs-comment">#This image is a microservice in golang for the Degree chaincode</span>
FROM golang:1.13.8-alpine AS build

COPY ./ /go/src/github.com/abstore
WORKDIR /go/src/github.com/abstore

<span class="hljs-comment"># Build application</span>
RUN  GOPROXY=<span class="hljs-string">&quot;https://goproxy.cn&quot;</span> GO111MODULE=on   go build -mod vendor -o chaincode -v .

<span class="hljs-comment"># Production ready image</span>
<span class="hljs-comment"># Pass the binary to the prod image</span>
FROM alpine:3.11 as prod

COPY --from=build /go/src/github.com/abstore/chaincode /app/chaincode

USER 1000

WORKDIR /app
CMD ./chaincode
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x811A;&#x672C;&#x5C31;&#x662F;&#x6784;&#x5EFA;&#x5408;&#x7EA6;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#xFF0C;&#x542F;&#x52A8;&#x5BB9;&#x5668;&#x8FD0;&#x884C;&#x5408;&#x7EA6;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x3002;</p>
<p>&#x5F00;&#x59CB;&#x6784;&#x5EFA;&#x955C;&#x50CF;</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> ~fabric-samples/chaincode/abstore/go

docker build -t chaincode/mycc2:1.0 .
</code></pre>
<p>&#x7136;&#x540E;&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x901A;&#x8FC7;<code>docker images |grep mycc2</code>&#x786E;&#x8BA4;
<img src="https://img-blog.csdnimg.cn/20200311153240591.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<h4 id="2452--&#x542F;&#x52A8;&#x5408;&#x7EA6;&#x5BB9;&#x5668;">2.4.5.2  &#x542F;&#x52A8;&#x5408;&#x7EA6;&#x5BB9;&#x5668;</h4>
<p>&#x4F7F;&#x7528;docker-compose&#x542F;&#x52A8;&#xFF0C;&#x7F16;&#x8F91;docker-compose-mycc.yaml&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-bash">version: <span class="hljs-string">&apos;2&apos;</span>
networks:
 default:
  external:
   name: net_byfn
services:
  <span class="hljs-comment">#&#x5408;&#x7EA6;&#x5BB9;&#x5668;</span>
  mycc2:
    <span class="hljs-comment">#&#x5B9A;&#x4E49;&#x4E3B;&#x673A;&#x540D;</span>
    container_name: mycc2.chiancode.com
    <span class="hljs-comment">#&#x4F7F;&#x7528;&#x7684;&#x955C;&#x50CF;</span>
    image: chaincode/mycc2:1.0
    <span class="hljs-comment">#&#x5BB9;&#x5668;&#x7684;&#x6620;&#x5C04;&#x7AEF;&#x53E3;</span>
    ports:
      - 9999:9999
    networks:
      - default
    <span class="hljs-comment">#&#x73AF;&#x5883;&#x53D8;&#x91CF;</span>
    privileged: <span class="hljs-literal">true</span>
    environment:
      - CHAINCODE_CCID=mycc2:6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454
      - CHAINCODE_ADDRESS=0.0.0.0:9999
</code></pre>
<p>&#x6CE8;&#x610F;CHAINCODE_CCID&#x4E00;&#x5B9A;&#x8981;&#x5BF9;&#x5E94;&#x6211;&#x4EEC;&#x4E4B;&#x524D;&#x5B89;&#x88C5;&#x597D;&#x7684;&#x5408;&#x7EA6;id</p>
<p>&#x542F;&#x52A8;&#x5BB9;&#x5668;&#xFF1A;</p>
<pre><code class="lang-bash">docker-compose <span class="hljs-_">-f</span> docker-compose-mycc.yaml up <span class="hljs-_">-d</span>
</code></pre>
<p>&#x4F7F;&#x7528;<code>docker ps</code>&#x786E;&#x8BA4;&#x5BB9;&#x5668;&#x662F;&#x5426;&#x542F;&#x52A8;&#x6210;&#x529F;</p>
<p><img src="https://img-blog.csdnimg.cn/20200311153556181.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<h1 id="3-&#x6D4B;&#x8BD5;&#x5916;&#x90E8;&#x5408;&#x7EA6;">3 &#x6D4B;&#x8BD5;&#x5916;&#x90E8;&#x5408;&#x7EA6;</h1>
<p>&#x5BF9;&#x90E8;&#x7F72;&#x597D;&#x7684;&#x5408;&#x7EA6;&#x8FDB;&#x884C;&#x6D4B;&#x8BD5;&#xFF0C;<code>docker exec -it cli bash</code>&#x8FDB;&#x5165;cli&#x5BB9;&#x5668;&#x3002;</p>
<p>init&#x5408;&#x7EA6;</p>
<pre><code class="lang-bash"> peer chaincode invoke -o orderer.example.com:7050 --tls <span class="hljs-literal">true</span> --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc201 --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --isInit -c <span class="hljs-string">&apos;{&quot;Args&quot;:[&quot;Init&quot;,&quot;a&quot;,&quot;100&quot;,&quot;b&quot;,&quot;100&quot;]}&apos;</span>
</code></pre>
<p>&#x67E5;&#x8BE2;&#x4EA4;&#x6613;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre><code class="lang-bash">peer chaincode query -C mychannel -n mycc201 -c <span class="hljs-string">&apos;{&quot;Args&quot;:[&quot;query&quot;,&quot;a&quot;]}&apos;</span>
</code></pre>
<p>&#x63A7;&#x5236;&#x53F0;&#x8F93;&#x51FA;&#xFF1A;
<img src="https://img-blog.csdnimg.cn/20200311153858384.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;">
&#x7ED3;&#x8BBA;&#xFF1A;&#x5341;&#x5206;&#x6210;&#x529F;&#x3002;</p>
<p>&#x5F53;&#x7136;&#x6210;&#x529F;&#x4E43;&#x5931;&#x8D25;&#x4E4B;&#x6BCD;&#xFF0C;&#x6211;&#x53EF;&#x662F;&#x8DDF;&#x6210;&#x529F;&#x9694;&#x4E86;&#x597D;&#x51E0;&#x4EE3;&#x7684;&#x5C0F;&#x4F19;&#x5B50;&#x3002;&#x4E0B;&#x9762;&#x5F00;&#x59CB;&#x4E00;&#x6CE2;&#x9519;&#x8BEF;&#x603B;&#x7ED3;</p>
<h2 id="31-&#x6709;&#x53EF;&#x80FD;&#x7684;&#x62A5;&#x9519;&#x53CA;&#x89E3;&#x51B3;&#x65B9;&#x6848;">3.1 &#x6709;&#x53EF;&#x80FD;&#x7684;&#x62A5;&#x9519;&#x53CA;&#x89E3;&#x51B3;&#x65B9;&#x6848;</h2>
<ol>
<li><code>Error: endorsement failure during invoke. response: status:500 message:&quot;error in simulation: failed to execute transaction 32e56961b2d9720f5e266ad0e61ce8b5ecaa5857e5b68b19a229ee3bd57da86f: could not launch chaincode mycc2:6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454: error building chaincode: malformed chaincode info at &apos;/var/hyperledger/production/externalbuilder/builds/mycc2-6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454/release/chaincode/server/connection.json&apos;: invalid character &apos;\\n&apos; in string literal&quot;</code></li>
</ol>
<blockquote>
<p>   &#x7B80;&#x5355;&#x6765;&#x8BF4;&#x5C31;&#x662F;&#x4E4B;&#x524D;&#x5728;&#x5408;&#x7EA6;&#x5B9A;&#x4E49;&#x7684;connection.json&#x5199;&#x5F97;&#x4E0D;&#x89C4;&#x8303;&#xFF0C;&#x76F4;&#x63A5;&#x8FDB;&#x53BB;&#x6240;&#x6709;&#x5B89;&#x88C5;&#x5408;&#x7EA6;&#x7684;&#x8282;&#x70B9;&#x91CC;&#x9762;&#x7684;
    /var/hyperledger/production/externalbuilder/builds/mycc2-6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454/release/chaincode/server/connection.json&#x8FD9;&#x4E2A;&#x76EE;&#x5F55;&#x5C31;&#x662F;&#x9519;&#x8BEF;&#x63D0;&#x793A;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#xFF0C;&#x6539;&#x4F60;conntion.json&#x6539;&#x5230;&#x7B26;&#x5408;json&#x89E3;&#x6790;&#x89C4;&#x8303;&#x4E3A;&#x6B62;&#x3002;</p>
</blockquote>
<ol>
<li><code>Error: endorsement failure during invoke. response: status:500 message:&quot;error in simulation: failed to execute transaction 3b30d51113c87ae5279a5a4efc1b20b926afda53b356da5d95026b8ab08a83ff: could not launch chaincode mycc2:6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454: error building chaincode: malformed chaincode info at &apos;/var/hyperledger/production/externalbuilder/builds/mycc2-6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454/release/chaincode/server/connection.json&apos;: invalid character &apos;~&apos; after top-level value&quot;</code></li>
</ol>
<blockquote>
<p>&#x540C;1</p>
</blockquote>
<ol>
<li><code>Error: endorsement failure during invoke. response: status:500 message:&quot;error in simulation: failed to execute transaction 6d756de4e462811da9a44aa0acf68c27e2fe66445de04c1083bb257da116ede1: could not launch chaincode mycc2:6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454: error building chaincode: malformed chaincode info at &apos;/var/hyperledger/production/externalbuilder/builds/mycc2-6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454/release/chaincode/server/connection.json&apos;: json: cannot unmarshal string into Go struct field ChaincodeServerUserData.tls_required of type bool&quot;</code></li>
</ol>
<blockquote>
<p>&#x8FD8;&#x662F;connection.json&#x7684;&#x9519;&#x8BEF;&#xFF0C;&#x4F46;&#x662F;&#x4E0D;&#x662F;&#x683C;&#x5F0F;&#xFF0C;tls_required&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x5FC5;&#x987B;&#x662F;boolean&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x53CC;&#x5F15;&#x53F7;&#x3002;</p>
</blockquote>
<ol>
<li><code>Error: endorsement failure during invoke. response: status:500 message:&quot;error in simulation: failed to execute transaction 556ddd1378a67cf0bab2e81cce7377a605bfdb8ac9a49b815680148b93b70a88: could not launch chaincode mycc2:6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454: connection to mycc2:6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454 failed: error cannot create connection for mycc2:6be5ebad4dabfda4e055b936658bf29a28079a2a4188915013998591426ac454: error creating grpc connection to 192.168.2.101:9999: failed to create new connection: connection error: desc = \&quot;transport: error while dialing: dial tcp 192.168.2.101:9999: connect: no route to host\&quot;&quot;</code></li>
</ol>
<blockquote>
<p>&#x5C31;&#x662F;&#x8282;&#x70B9;&#x8FDE;&#x4E0D;&#x4E0A;&#x60A8;&#x5916;&#x90E8;&#x542F;&#x52A8;&#x7684;&#x5408;&#x7EA6;&#x670D;&#x52A1;&#xFF0C;&#x786E;&#x8BA4;&#x5408;&#x7EA6;&#x662F;&#x5426;&#x6B63;&#x5E38;&#x542F;&#x52A8;&#xFF0C;&#x518D;&#x8005;telnet&#x4E00;&#x4E0B;&#x770B;&#x770B;ip:port&#x662F;&#x4E0D;&#x662F;&#x901A;&#x7684;&#xFF0C;&#x6539;&#x5230;&#x901A;&#x4E3A;&#x6B62;&#x3002;</p>
</blockquote>
<h1 id="4&#x603B;&#x7ED3;">4.&#x603B;&#x7ED3;</h1>
<p>&#x5BF9;&#x5B9E;&#x73B0;&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x542F;&#x52A8;&#x5408;&#x7EA6;&#x603B;&#x7ED3;&#x6D41;&#x7A0B;&#x5982;&#x4E0B;&#xFF1A; </p>
<p><img src="https://img-blog.csdnimg.cn/20200311155533903.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI4NTQwNDQz,size_16,color_FFFFFF,t_70" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<p>&#x5176;&#x4E2D;&#x6784;&#x5EFA;&#x5916;&#x90E8;&#x5408;&#x7EA6;&#x5BF9;&#x4E8E;docker&#x5F62;&#x5F0F;&#x6765;&#x8BF4;&#x662F;&#x6784;&#x5EFA;&#x5408;&#x7EA6;&#x955C;&#x50CF;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x672C;&#x5730;&#x8DD1;&#x7684;&#x53EF;&#x4EE5;&#x4E0D;&#x9700;&#x8981;&#x8FD9;&#x4E00;&#x6B65;&#x3002;</p>
<p>&#x5B9E;&#x8DF5;&#x5B8C;&#x6574;&#x4E00;&#x4E2A;&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x542F;&#x52A8;&#x5408;&#x7EA6;&#x7684;&#x8FC7;&#x7A0B;&#xFF0C;&#x5176;&#x5B9E;&#x6BD4;&#x8F83;&#x75DB;&#x82E6;&#xFF0C;&#x56E0;&#x4E3A;&#x5B98;&#x65B9;&#x6587;&#x6863;&#x786E;&#x5B9E;&#x63CF;&#x8FF0;&#x6709;&#x70B9;&#x4E71;&#xFF0C;&#x50CF;&#x6211;&#x8FD9;&#x79CD;&#x4E00;&#x822C;&#x4EBA;&#x5F88;&#x5BB9;&#x6613;&#x5C31;&#x4F1A;&#x5404;&#x79CD;&#x8FF7;&#xFF0C;&#x4F46;&#x662F;&#x7ECF;&#x8FC7;&#x5927;&#x5BB6;&#x8BA8;&#x8BBA;&#x4EE5;&#x53CA;&#x6E90;&#x7801;&#x5206;&#x6790;&#x540E;&#xFF0C;&#x9664;&#x4E86;&#x89E3;&#x51B3;&#x95EE;&#x9898;&#x4E4B;&#x5916;&#xFF0C;&#x5BF9;fabric&#x8FD9;&#x4E2A;&#x65B0;&#x7279;&#x6027;&#x4E5F;&#x6709;&#x4E86;&#x66F4;&#x6DF1;&#x7684;&#x8BA4;&#x8BC6;&#xFF0C;&#x901A;&#x8FC7;&#x5916;&#x90E8;&#x6784;&#x5EFA;&#x65B9;&#x5F0F;&#xFF0C;&#x5408;&#x7EA6;&#x4E0D;&#x518D;&#x662F;&#x53EA;&#x80FD;&#x662F;&#x4E00;&#x4E2A;&#x5BB9;&#x5668;&#x5F62;&#x5F0F;&#x5B58;&#x5728;&#xFF0C;&#x4ED6;&#x53EF;&#x4EE5;IDE&#x8FD0;&#x884C;debug&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x7F16;&#x8BD1;&#x6210;&#x4E8C;&#x8FDB;&#x5236;&#x8FD0;&#x884C;&#xFF0C;&#x5BF9;&#x4E8E;&#x4E0D;&#x540C;&#x73AF;&#x5883;&#x4E0D;&#x540C;&#x5F00;&#x53D1;&#x8005;&#x6765;&#x8BF4;&#x6709;&#x4E86;&#x7075;&#x6D3B;&#x7684;&#x9009;&#x62E9;&#xFF0C;&#x867D;&#x7136;&#x6682;&#x65F6;&#x53EA;&#x652F;&#x6301;go&#x5408;&#x7EA6;&#x3002;</p>
<p>&#x6E90;&#x7801;&#xFF1A; <a href="https://github.com/llzz9595/fabric-learning" target="_blank">https://github.com/llzz9595/fabric-learning</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="chap10.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 调试go智能合约">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"外部构建启动合约","level":"1.4.5","depth":2,"next":{"title":"SDK实践","level":"1.5","depth":1,"ref":"","articles":[{"title":"基于Java SDK实现合约交易","level":"1.5.1","depth":2,"path":"chap12.md","ref":"chap12.md","articles":[]}]},"previous":{"title":"调试go智能合约","level":"1.4.4","depth":2,"path":"chap10.md","ref":"chap10.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"chap11.md","mtime":"2020-03-12T03:45:29.206Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-03-12T04:26:38.647Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

